﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Election
{
    public partial class UngCuVienUC : UserControl
    {

        public UngCuVienUC(String id, String name, int voteQuan, String maUCV)
        {
            InitializeComponent();
            this.idLbl.Text = id;
            this.nameLbl.Text = name;
            this.voteQuanLbl.Text = voteQuan.ToString();            
           try
           {
               //CHECK HERE
               //replace imagepath to code below
               if (File.Exists(orcl.imagePath + maUCV + ".jpg"))
               {
                   this.pictureBox.Image = Image.FromFile(orcl.imagePath + maUCV + ".jpg");
               }
               else
                   if (File.Exists(orcl.imagePath + maUCV + ".png"))
                   {
                       this.pictureBox.Image = Image.FromFile(orcl.imagePath + maUCV + ".png");
                   }
                   //else
                   //    this.pictureBox.Image = Image.FromFile(orcl.imagePath + "invalid.png");
              
           }
           catch (System.Exception ex)
           {
               MessageBox.Show(ex.Message);
           }
            
        }

        public UngCuVienUC()
        {
            InitializeComponent();
            this.idLbl.Text = "Unavailable";
            this.nameLbl.Text = "";
            this.voteQuanLbl.Text = "0";
            //this.pictureBox.Image = Image.FromFile("image/A0912430.jpg");             
                //CHECK HERE
                //replace imagepath to code below                
            //this.pictureBox.Image = Image.FromFile("image/invalid.png");
            
        }
        public void setUngCuVienInfo(String id, String name, int voteQuan, String maUCV)
        {
            this.idLbl.Text = id;
            this.nameLbl.Text = name;
            this.voteQuanLbl.Text = voteQuan.ToString();
            //this.pictureBox.Image = Image.FromFile("image/A0912430.jpg");
            if (File.Exists(orcl.imagePath + maUCV + ".jpg"))
            {
                this.pictureBox.Image = Image.FromFile(orcl.imagePath + maUCV + ".jpg");
            }
            else
                if (File.Exists(orcl.imagePath + maUCV + ".png"))
                {
                    this.pictureBox.Image = Image.FromFile(orcl.imagePath + maUCV + ".png");
                }
                //else
                //    this.pictureBox.Image = Image.FromFile(orcl.imagePath +"invalid.png");
        }
    }
}
